﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SwenAssigment.Classes
{
    public class ACList
    {
        //page that allow all user
        static List<String> AllowNormal;
        static List<String> AllowManagement;
        static List<String> AllowAdmin;
        static List<String> AllowAll;
        public static List<String> AllowAllList()
        {
            AllowAll = new List<string>();
            AllowAll.Add("default.aspx");
            //Error page is html and it can be access by all
            //
            //AllowAll.Add("DutyReport.aspx");
            //AllowAll.Add("AssignDuty.aspx");
            AllowAll.Add("Logout.aspx");
            AllowAll.Add("CreateAcc.aspx");
            return AllowAll;
        }
        public static List<String> AllowNList()
        {
            AllowNormal = new List<string>();
            AllowNormal.Add("BookingCheckIn.aspx");
            AllowNormal.Add("BookingCheckOut.aspx");
            AllowNormal.Add("BookingDetail.aspx");
            AllowNormal.Add("BookingSearch.aspx");
            AllowNormal.Add("BookingUpdate.aspx");
            AllowNormal.Add("GuestDetail.aspx");
            AllowNormal.Add("GuestExist.aspx");
            AllowNormal.Add("GuestNew.aspx");
            AllowNormal.Add("GuestSearch.aspx");
            AllowNormal.Add("GuestUpdate.aspx");
            AllowNormal.Add("RoomAvalibility.aspx");
            AllowNormal.Add("RoomDetail.aspx");
            AllowNormal.Add("RoomUpdate.aspx");
            AllowNormal.Add("Reporting.aspx");
            return AllowNormal;
        }
        public static List<String> AllowMList()
        {
            AllowManagement = new List<string>();
            AllowManagement.Add("staffedit.aspx");
            AllowManagement.Add("StaffCreation.aspx");
            AllowManagement.Add("StaffOverview.aspx");
            AllowManagement.Add("StaffSuccessfulCreation.aspx");
            AllowManagement.Add("StaffSuccessfulUpdate.aspx");
            AllowManagement.Add("StaffSuccessfulDelete.aspx");
            AllowManagement.Add("StaffSearch.aspx");
            AllowManagement.Add("DutyReport.aspx");
            AllowManagement.Add("AssignDuty.aspx");
            AllowManagement.Add("ReportOccupancy.aspx");
            //AllowManagement.Add("/Logout.aspx");
            return AllowManagement;
        }
        public static List<String> AllowAList()
        {
            AllowAdmin = new List<string>();
            AllowAdmin.Add("AccountManageDetail.aspx");
            AllowAdmin.Add("AccountManagement.aspx");
            AllowAdmin.Add("AccRequest.aspx");
            AllowAdmin.Add("AddUser.aspx");
            AllowAdmin.Add("PasswordRequest.aspx");
            AllowAdmin.Add("UserEdit.aspx");
            AllowAdmin.Add("Log.aspx");
            return AllowAdmin;
        }
        public static bool AccessRight(String CPage, String Role)
        {
            foreach (String Checking in AllowAllList())
            {
                if (Checking.ToLower() == CPage)
                {
                    return true;
                }
            }
            foreach (String Checking in AllowNList())
            {
                if (Checking.ToLower() == CPage && (Role == "Normal" || Role == "Management" || Role == "Admin"))
                {
                    return true;
                }
            }
            foreach (String Checking in AllowMList())
            {
                if (Checking.ToLower() == CPage && (Role == "Management" || Role == "Admin"))
                {
                    return true;
                }
            }
            foreach (String Checking in AllowAList())
            {
                if (Checking.ToLower() == CPage && Role == "Admin")
                {
                    return true;
                }
            }
            return false;
        }
    }
}